home *** CD-ROM | disk | FTP | other *** search
/ Aminet 41 / Aminet 41 (2001)(Schatztruhe)[!][Feb 2001].iso / Aminet / gfx / edit / AmiCAD_2.06.lha / AmiCAD / ARexx / ChercherTexte.AmiCAD < prev    next >
Text File  |  2000-04-13  |  2KB  |  85 lines

  1. /* Recherche d'un texte
  2. Version 1.00: 3 juin 1999
  3. Version 1.01: 13 avril 2000 (modif fonctions OBJECTS, LOCK, UNLOCK)
  4. $VER: 1.01 (© R.Florac, 13 avril 2000) */
  5.  
  6. options results     /* indispensable pour récupérer le résultat des macros */
  7.  
  8. signal on error     /* pour l'interception des erreurs */
  9. signal on syntax
  10.  
  11. texte=""
  12. 'LOCK:FIRSTSEL'; i=result
  13. if i>0 then do
  14.     'IF(TYPE('i')==TEXTE,READTEXT('i'),"")'; texte=result
  15.     if result="" then do
  16.     'IF(TYPE('i')==REFERENCE,READTEXT('i'),"")'; texte=result
  17.     if result="" then do
  18.         'IF(TYPE('i')==VALEUR,READTEXT('i'),"")'; texte=result
  19.     end
  20.     end
  21. end
  22.  
  23. if texte="" then do
  24.     'ASKTEXT("Texte à chercher ?","")'
  25.     texte=result
  26. end
  27. if texte='' then do
  28.     'UNLOCK'
  29.     exit
  30. end
  31.  
  32. call 'Travail:AmiCAD/Arexx/InitObjets.AmiCAD'
  33.  
  34. nf=0
  35. 'TITLE("Recherche en cours..."):OBJECTS'
  36. o=result
  37. do i=1 to o
  38.     'IF(TYPE('i')==TEXTE,READTEXT('i'),"")'
  39.     t=result
  40.     if t ~= "" then do
  41.     if t=texte then do
  42.         'MARK('i')'
  43.         nf=nf+1
  44.     end
  45.     end
  46. end
  47.  
  48. i=1
  49. do while i>0
  50.     'FINDREF('i',"'texte'")'; i=result
  51.     if i>0 then do
  52.     'MARK('i'):MARK(GETREF('i'))'
  53.     nf=nf+1
  54.     i=i+1
  55.     if i>o then leave
  56.     end
  57. end
  58.  
  59. i=1
  60. do while i>0
  61.     'FINDVAL('i',"'texte'")'; i=result
  62.     if i>0 then do
  63.     'MARK('i'):MARK(GETVAL('i'))'
  64.     nf=nf+1
  65.     i=i+1
  66.     if i>o then leave
  67.     end
  68. end
  69.  
  70. if nf > 0 then do
  71.     'TITLE(""):MESSAGE("'texte' trouvé"+CHR(10)+"'nf' fois"):UNLOCK'
  72. end
  73. else 'TITLE(""):MESSAGE("'texte'"+CHR(10)+"non trouvé"):UNLOCK'
  74. exit
  75.  
  76. /* Traitement des erreurs, interruption du programme */
  77. syntax:
  78. erreur=RC
  79. 'MESSAGE("Erreur de syntaxe"+CHR(10)+"en ligne 'SIGL'"+CHR(10)+"'errortext(erreur)'"):UNLOCK'
  80. exit
  81.  
  82. error:
  83. 'MESSAGE("Erreur en ligne 'SIGL'"):UNLOCK'
  84. exit
  85.